package com.myz.rabbitmq.study8;

import com.myz.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

public class Consumer02 {
    // 普通队列名称
    public static final String DEAD_QUEUE = "dead_queue";

    public static void main(String[] args) throws Exception {
        // 1.获取信道
        Channel channel = RabbitMqUtils.getChannel();
        // 2.声明交换机 declare exchange
        // 3.声明队列 declare queue
        DeliverCallback deliverCallback = (consumeTag,message) -> {
            System.out.println("Consumer02 receive a message:"+new String(message.getBody(),"UTF-8"));
        };
        // 4.绑定队列
        // 5.接收消息
        channel.basicConsume(DEAD_QUEUE,true,deliverCallback, (CancelCallback) null);
    }
}
